package com.rxyb.authority.gateway.controller;


import com.rxyb.authority.gateway.dto.role.*;
import com.rxyb.authority.service.OpsAuthorityRoleService;
import com.rxyb.core.respone.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author DUYH
 * @since 2020-05-29
 */
@RestController
@RequestMapping("/role")
public class OpsAuthorityRoleController {

    @Autowired(required = false)
    private OpsAuthorityRoleService opsAuthorityRoleService;

    /**
     * 创建
     *
     * @author duyh
     */
    @PostMapping(value = "create", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public R<CreateRoleRsp> create(@Validated @RequestBody CreateRoleReq createRoleReq) {
        return opsAuthorityRoleService.create(createRoleReq);
    }

    /**
     * 删除
     *
     * @author duyh
     */
    @PostMapping(value = "remove", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public R<DeleteRoleRsp> remove(@Validated @RequestBody DeleteRoleReq deleteRoleReq) {
        return opsAuthorityRoleService.remove(deleteRoleReq);
    }

    /**
     * 修改
     *
     * @author duyh
     */
    @PostMapping(value = "update", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public R<UpdateRoleRsp> update(@Validated @RequestBody UpdateRoleReq updateRoleReq) {
        return opsAuthorityRoleService.update(updateRoleReq);
    }

    /**
     * 详情
     *
     * @author duyh
     */
    @PostMapping(value = "query", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public R<GetRoleInfoRsp> query(@Validated @RequestBody GetRoleInfoReq getRoleInfoReq) {
        return opsAuthorityRoleService.query(getRoleInfoReq);
    }

    /**
     * 列表
     *
     * @author duyh
     */
    @PostMapping(value = "list", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public R<GetRoleListRsp> list(@Validated @RequestBody GetRoleListReq getRoleListReq) {
        return opsAuthorityRoleService.list(getRoleListReq);
    }
}
